/**
 * 2008 Sylvain Dudoit (All rights reserved)
 *
 * $Id$
 */
package org.bankabeule.impl;

import org.bankabeule.Account;
import org.bankabeule.AccountTypeEnum;
import org.bankabeule.BankabeuleFactory;
import org.bankabeule.BankabeulePackage;
import org.bankabeule.Date;
import org.bankabeule.Element;
import org.bankabeule.Model;
import org.bankabeule.MoneyEnum;
import org.bankabeule.Operation;
import org.bankabeule.OperationTypeEnum;
import org.bankabeule.Tag;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class BankabeuleFactoryImpl extends EFactoryImpl implements
		BankabeuleFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static BankabeuleFactory init() {
		try {
			BankabeuleFactory theBankabeuleFactory = (BankabeuleFactory) EPackage.Registry.INSTANCE
					.getEFactory("org.bankabeule");
			if (theBankabeuleFactory != null) {
				return theBankabeuleFactory;
			}
		} catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new BankabeuleFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BankabeuleFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
		case BankabeulePackage.MODEL:
			return createModel();
		case BankabeulePackage.ACCOUNT:
			return createAccount();
		case BankabeulePackage.TAG:
			return createTag();
		case BankabeulePackage.OPERATION:
			return createOperation();
		case BankabeulePackage.ELEMENT:
			return createElement();
		case BankabeulePackage.DATE:
			return createDate();
		default:
			throw new IllegalArgumentException("The class '" + eClass.getName()
					+ "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
		case BankabeulePackage.ACCOUNT_TYPE_ENUM:
			return createAccountTypeEnumFromString(eDataType, initialValue);
		case BankabeulePackage.MONEY_ENUM:
			return createMoneyEnumFromString(eDataType, initialValue);
		case BankabeulePackage.OPERATION_TYPE_ENUM:
			return createOperationTypeEnumFromString(eDataType, initialValue);
		default:
			throw new IllegalArgumentException("The datatype '"
					+ eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
		case BankabeulePackage.ACCOUNT_TYPE_ENUM:
			return convertAccountTypeEnumToString(eDataType, instanceValue);
		case BankabeulePackage.MONEY_ENUM:
			return convertMoneyEnumToString(eDataType, instanceValue);
		case BankabeulePackage.OPERATION_TYPE_ENUM:
			return convertOperationTypeEnumToString(eDataType, instanceValue);
		default:
			throw new IllegalArgumentException("The datatype '"
					+ eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Model createModel() {
		ModelImpl model = new ModelImpl();
		return model;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Account createAccount() {
		AccountImpl account = new AccountImpl();
		return account;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Tag createTag() {
		TagImpl tag = new TagImpl();
		return tag;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Operation createOperation() {
		OperationImpl operation = new OperationImpl();
		return operation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Element createElement() {
		ElementImpl element = new ElementImpl();
		return element;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Date createDate() {
		DateImpl date = new DateImpl();
		return date;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AccountTypeEnum createAccountTypeEnumFromString(EDataType eDataType,
			String initialValue) {
		AccountTypeEnum result = AccountTypeEnum.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException("The value '" + initialValue
					+ "' is not a valid enumerator of '" + eDataType.getName()
					+ "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertAccountTypeEnumToString(EDataType eDataType,
			Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MoneyEnum createMoneyEnumFromString(EDataType eDataType,
			String initialValue) {
		MoneyEnum result = MoneyEnum.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException("The value '" + initialValue
					+ "' is not a valid enumerator of '" + eDataType.getName()
					+ "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertMoneyEnumToString(EDataType eDataType,
			Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OperationTypeEnum createOperationTypeEnumFromString(
			EDataType eDataType, String initialValue) {
		OperationTypeEnum result = OperationTypeEnum.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException("The value '" + initialValue
					+ "' is not a valid enumerator of '" + eDataType.getName()
					+ "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertOperationTypeEnumToString(EDataType eDataType,
			Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BankabeulePackage getBankabeulePackage() {
		return (BankabeulePackage) getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static BankabeulePackage getPackage() {
		return BankabeulePackage.eINSTANCE;
	}

} //BankabeuleFactoryImpl
